package sample;

import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;



public class Register  extends Application {
    private String password="";
//    private void setOnClickAction(AnchorPane root, TextField removeFiled, TextField addField) {
//        // 设置点击 👁 时图标及输入框的切换，以便显示/隐藏密码
//        // 此外还需要设置控件的 password 文本，以便同步
//        removeFiled.setOnMouseClicked(event -> {
//            // 粗略判断是否移动到 👁 附近的位置
//            String password = removeFiled.getText();
//            double x = removeFiled.getWidth() + 70;
//            if (event.getSceneX() > x) {
//                Integer index = root.getChildren().indexOf(removeFiled);
//                root.getChildren().remove(removeFiled);
//                root.getChildren().add(index,addField);
//                addField.setText(password);
//            }
//        });
//    }
    public void start(Stage primaryStage) throws  Exception{
        try{
            TextField remove,add;
            AnchorPane root  = FXMLLoader.load(getClass().getResource("/fxml/register.fxml"));
//            remove = (TextField) root.lookup("#password");
//            remove.textProperty().addListener((observable, oldValue, newValue) -> password = newValue);
//            add  =  new TextField();
//            add.textProperty().addListener((observable, oldValue, newValue) -> password = newValue);
//            setOnClickAction(root, remove,add);
//            setOnClickAction(root, add, remove);
            Scene sc;
            sc = new Scene(root,450,430);
            primaryStage.setScene(sc);
            primaryStage.setTitle("注册页面");
            primaryStage.setResizable(false);
            primaryStage.show();
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        launch(args);
    }


}
